<?php
class Blogmodel extends Model {

    var $title   = '';
    var $content = '';
    var $date    = '';

    function Blogmodel()
    {
        // Call the Model constructor
        parent::Model();
    }
    
    function get_last_ten_entries()
    {
        $query = $this->db->get('entries', 10);
        return $query->result();
    }

    function insert_entry()
    {
        $this->title   = $_POST['title']; // please read the below note
        $this->content = $_POST['content'];
        $this->date    = date('Y-m-d H-i-s',time());

		$this->db->set('title',$this->title)->set('content',$this->content)->set('date',$this->date)->insert('entries');
    }

    function update_entry()
    {
        $this->title   = $_POST['title'];
        $this->content = $_POST['content'];
        $this->date    = date('Y-m-d H-i-s',time());

        $this->db->update('entries', $this, array('id' => $_POST['id']));
		
    }

}
?>